//使用循环，分别录入5个功课的成绩，并计算平均分并输出
function fn() {
    let sum = 0;
    let average = 0;
    for (let i = 0; i < 5;) {
        let score = prompt(`输入第${i+1}门功课的成绩`)
        if (score === null) {
            alert('请输入数字')
            continue
        }
        score = score.trim()
        if (isNaN(score) || score === '') {
            alert('请输入数字')
            continue
        }
        i++
        score = parseInt(score)
        sum += score
    }
    average = sum / 5
    document.write('5门功课的平均成绩：' + average)
}
fn()